package pt.isel.lercm.projectmanager.spring.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import pt.isel.lercm.projectmanager.spring.dao.ConstanteDAO;
import pt.isel.lercm.projectmanager.spring.model.Constante;

@Service("ConstanteService")
@Transactional(readOnly = true)
public class ConstanteService implements IConstanteService {

	@Autowired
	ConstanteDAO constanteDao;

	public ConstanteDAO getConstanteDao() {
		return constanteDao;
	}

	public void setConstanteDao(ConstanteDAO constanteDao) {
		this.constanteDao = constanteDao;
	}

	
	@Transactional(readOnly = false)
	@Override
	public void add(Constante object) {
		getConstanteDao().addObject(object);
	}
	
	@Transactional(readOnly = false)
	@Override
	public void update(Constante object) {
		getConstanteDao().updateObject(object);
	}

	@Transactional(readOnly = false)
	@Override
	public void delete(Constante object) {
		getConstanteDao().deleteObject(object);
	}

	@Override
	public Constante getById(int id) {
		return getConstanteDao().getByid(id);
	}

	@Override
	public List<Constante> getAll() {
		return getConstanteDao().getAll();
	}

	@Override
	public String getValorByName(String nome) {
		return getConstanteDao().getValorByName(nome);
	}
	
	@Override
	public Constante getByName(String nome) {
		return getConstanteDao().getByName(nome);
	}
	
}
